package com.example.wan1.view.user;

import com.example.wan1.base.mvp.BasePresenter;
import com.example.wan1.data.BaseObserver;
import com.example.wan1.data.RetrofitUtil;
import com.example.wan1.data.RxSchedulers;
import com.example.wan1.model.ArticleBean;
import com.example.wan1.model.CoinBean;
import com.example.wan1.model.common.CommonResList;
import com.example.wan1.model.common.CommonResMultiList;
import com.example.wan1.view.login.LoginContract;

import javax.inject.Inject;

/***
 * 创建时间：2020/7/26 19:38
 * 创建人：10850
 * 功能描述：
 */
public class UserCenterPresenter implements UserCenterContract.Presenter {

    @Inject
    UserCenterContract.View mView;

    @Inject
    public UserCenterPresenter() {
    }

    @Override
    public void getShareList(int id, int page) {
        RetrofitUtil.getInstance().getShareList(id, page)
                .compose(RxSchedulers.observableIO2Main())
                .subscribe(new BaseObserver<CommonResMultiList<CoinBean, CommonResList<ArticleBean>>>() {
                    @Override
                    public void onSuccess(CommonResMultiList<CoinBean, CommonResList<ArticleBean>> result) {
                        mView.onSuccess(result);
                    }

                    @Override
                    public void onFailure(Throwable e, String errorMsg) {
                        mView.onFailure(e.getMessage());
                    }
                });
    }
}
